using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace DiceRoller.Util {
  public class InputHistory {

    private ArrayList history;
    private int index;

    public InputHistory() {
      history = new ArrayList();
      history.Add("");
      index = 0;
    }

    public void Add(Object o) {
      history.Remove("");
      history.Add(o);
      history.Add("");
      index = history.Count - 1;
    }

    public virtual Object this[int index] {
      get {
        return history[index];
      }
    }

    public virtual Object Previous {
      get {
        if(index >= 1) {
          return history[--index];
        }
        else {
          return history[index];
        }
      }
    }

    public virtual Object Next {
      get {
        if(index < history.Count - 1) {
          return history[++index];
        }
        else {
          return history[index];
        }
      }
    }

    public virtual Object Last {
      get {
        return history[history.Count - 1];
      }
    }

    public int Count {
      get {
        return history.Count;
      }
    }

    public void Remove(Object o) { }

  }
}
